package cn.com.duiba.millionaire.center.biz.dao.impl;

import cn.com.duiba.millionaire.center.biz.constants.DatabaseSchema;
import cn.com.duiba.millionaire.center.biz.dao.BaseDao;
import cn.com.duiba.millionaire.center.biz.dao.MillionaireShareCodeRecordDao;
import cn.com.duiba.millionaire.center.biz.entity.MillionaireShareCodeRecordEntity;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created by sty on 1/19/18.
 */
@Repository
public class MillionaireShareCodeRecordDaoImpl extends BaseDao implements MillionaireShareCodeRecordDao {
    @Override
    public MillionaireShareCodeRecordEntity insert(MillionaireShareCodeRecordEntity millionaireShareCodeRecordEntity) {
        insert("insert",millionaireShareCodeRecordEntity);
        return millionaireShareCodeRecordEntity;
    }

    @Override
    public MillionaireShareCodeRecordEntity findByShareCodeAndCidAndAppId(String shareCode, Long consumerId, Long appId) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("shareCode", shareCode);
        params.put("consumerId", consumerId);
        params.put("appId", appId);
        return selectOne("selectByShareCodeAndCidAndAppId",params);
    }

    @Override
    protected DatabaseSchema chooseSchema() {
        return DatabaseSchema.MILLIONAIRE_CONFIG;
    }
}
